﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace XM
{
    public partial class LYH_lb : Form
    {
        public LYH_lb()
        {
            InitializeComponent();
        }

        private void LYH_lb_Load(object sender, EventArgs e)
        {
            for (int i = 0; i < 2; i++)
            {
                string lj = Application.StartupPath + string.Format("\\zzry\\{0}.png", i);
                Image img = Image.FromFile(lj);
                imageList3.Images.Add(img);
            }
            
            
            if (YZ.LKdl == 1)
            {
                pictureBox22.Enabled = false;
                //pictureBox22.Image = imageList3.Images[0];
                string picPath = Application.StartupPath + "\\logo.png";
                pictureBox22.Image = Image.FromFile(picPath);
            }


            //循环输出button控件，显示正在热映电影名称
            for (int i = 0; i < imageList1.Images.Count; i++)
            {
                Button but = new Button();
                but.Text = "电影"+(i+1);
                but.Anchor = AnchorStyles.Top;
                but.Location = new Point(50 + i * 140, 300);
                but.Click += but_Click;
                this.Controls.Add(but);
            }

            //循环输出picturebox控件，显示正在热映
            foreach (Image item in imageList1.Images)
            {
                PictureBox pic = new PictureBox();

                pic.Size = new Size(100, 120);
                pic.Margin = new Padding(0, 0, 40, 0);
                pic.Image = item;
                flowLayoutPanel1.Controls.Add(pic);

                pic.Click += pic_Click;

                pic.Cursor = Cursors.Hand;

            }

            //循环输出picturebox控件，显示即将上映
            for (int i = 0; i < imageList2.Images.Count; i++)
            {
                PictureBox pic1 = new PictureBox();

                pic1.Size = new Size(100, 120);
                if (i < 4)
                {
                    pic1.Margin = new Padding(0, 20, 40, 0);
                }
                else
                {
                    pic1.Margin = new Padding(0, 50, 40, 0);
                }
                pic1.Image = imageList2.Images[i];
                flowLayoutPanel2.Controls.Add(pic1);

                pic1.Click += pic1_Click;

                pic1.Cursor = Cursors.Hand;
                pic1.SendToBack();

            }

            //循环输出button控件，显示即将上映电影名称
            for (int i = 0; i < imageList2.Images.Count; i++)
            {
                Button but1 = new Button();
                but1.Text = "电影"+(i+1);
                but1.Anchor = AnchorStyles.Top;
                if (i < 4)
                {
                    but1.Location = new Point(50 + i * 140, 552);
                }
                else
                {
                    but1.Location = new Point(50 + (i - 4) * 140, 723);
                }
                but1.Click += but1_Click;
                this.Controls.Add(but1);
                but1.BringToFront();
            }
        }
        //电影名称单击事件
        void but1_Click(object sender, EventArgs e)
        {
            //throw new NotImplementedException();
            LYH_xq from = new LYH_xq();
            from.ShowDialog();
        }
        //电影图片单击事件
        void pic1_Click(object sender, EventArgs e)
        {
            //throw new NotImplementedException();
            LYH_xq from = new LYH_xq();
            from.ShowDialog();
        }
        //电影名称单击事件
        void but_Click(object sender, EventArgs e)
        {
            //throw new NotImplementedException();
            LYH_xq from = new LYH_xq();
            from.ShowDialog();
        }
        //电影图片单击事件
        void pic_Click(object sender, EventArgs e)
        {
            //throw new NotImplementedException();
            LYH_xq from = new LYH_xq();
            from.ShowDialog();
        }
        //菜单栏悬浮变色
        private void t1_MouseEnter_1(object sender, EventArgs e)
        {
            t1.ForeColor = Color.Red;
        }
        //菜单栏离开恢复颜色
        private void t1_MouseLeave_1(object sender, EventArgs e)
        {
            t1.ForeColor = Color.Black;
        }
        //登录图标单击事件
        private void pictureBox22_Click(object sender, EventArgs e)
        {
            LK_dl from = new LK_dl();
            from.ShowDialog();
            if (YZ.LKdl == 1)
            {
                pictureBox22.Enabled = false;
                string picPath = Application.StartupPath + "\\logo.png";
                pictureBox22.Image = Image.FromFile(picPath);
            }
        }

        private void listView1_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        private void label3_Click(object sender, EventArgs e)
        {

        }

        private void flowLayoutPanel2_Paint(object sender, PaintEventArgs e)
        {

        }

        private void LYH_lb_FormClosed(object sender, FormClosedEventArgs e)
        {
        }

        private void t4_Click(object sender, EventArgs e)
        {
            bd from = new bd();
            from.Show();
            this.Hide();
        }

        private void t5_Click(object sender, EventArgs e)
        {
            LY1.rd from = new LY1.rd();
            from.Show();
            this.Hide();
        }

        private void LYH_lb_FormClosed_1(object sender, FormClosedEventArgs e)
        {
            System.Environment.Exit(0);
        }

        private void pictureBox21_Click(object sender, EventArgs e)
        {

        }
    }
}
